/*
ID: wxm071
PROG: ride
LANG: C++14
*/
#include <vector>
#include <fstream>
#include <iostream>

using namespace std;

//str=ABC
int change(string str){
    int res = 1;

    for(char c: str){
        res *= ((int)c - 65 + 1); 
    }

    res = res % 47;

    return res;
}

int main(int argc, char const *argv[])
{
    //文件读取到string
    ifstream ifs("ride.in");
    ofstream ofs("ride.out");

    string x, y;
    
    ifs >> x;
    ifs >> y;
    
    int a = change(x);
    int b = change(y);

    string res;

    if (a == b){
        res =  "GO";
    }
    else{
        res = "STAY";
    }
    
    cout << res << endl;
    ofs << res <<endl;
    return 0;
}
